package leetcode;

import java.util.Arrays;

/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q2567.java
 * @Author : WangRuoyu
 * @Date 2023/2/23 9:25
 */
public class Q2567 {
    public int minimizeSum(int[] nums) {
        Arrays.sort(nums);
        int res = Math.min(nums[nums.length - 1] - nums[2], nums[nums.length - 3] - nums[0]);
        res = Math.min(res, nums[nums.length - 2] - nums[1]);
        return res;
    }

    public static void main(String[] args) {
        Q2567 sl = new Q2567();
        int[] nums = {1, 4, 3};
        System.out.println(sl.minimizeSum(nums));
    }
}